home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
jwpsrc.zip
/
JWP.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-28
|
26KB
|
598 lines
/* Copyright (C) Stephen Chung, 1991-1992. All rights reserved. */
#include <windows.h>
#include "toolbar.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mem.h>
#include <dos.h>
#include <io.h>
#include <time.h>
#define CTL3D /* 3D Dialog Boxes */
/* Macros */
#define KANJI unsigned short int
#define MAGIC 0x42022667L
#define JWPFILEVERSION "B2"
#define NRSUMMARIES 5
#define NRHEADERS 3
#define MAXLINELEN 512 /* General length of a line */
#define MAXFILENAMELEN 120 /* General length of filenames */
#define BUFSIZE 1024 /* General buffer for things */
#define TEXTBLOCKSIZE 256 /* One unit of text */
#define UNDOTEXTSIZE 16 /* One unit of undo text */
#define MAXFILES 10 /* Maximum number of files opened */
#define MAXGLOSSARY 500 /* Maximum number of glossaries */
#define PROGNAME "JWP" /* Name of the program */
#define NAMELEN 40 /* General length for names */
#define BLOCKSIZE 10240L /* Optimal memory page size */
#define C64K (60L * 1024L) /* 64K Blocks */
#define CPOSPAGESIZE BLOCKSIZE /* Page size for the CPOS array */
#define BADKANJI 0x2223 /* Black square */
#define ISASCII(x) ((HIBYTE(x) & 0x7f) == 0)
#define ISKANJI(x) ((HIBYTE(x) & 0x7f) != 0)
#define KANJIAT(x,y) ISKANJI(CHAROF(x,y))
#define KANJIPOS(x) KANJIAT(x,POSOF(x))
#define BASEFONT (global.basefont)
#define PRINTFONT (global.printfont)
#define SYSFONT (global.sysfont)
#define LINEGAP(x) ((x)->spacing / 2)
#define CHARGAP(x) ((x)->leading / 2)
#define BlockAlloc(x) SegHeapAlloc(x)
#define BlockRealloc(x, n) SegHeapRealloc(x, n)
#define FreeBlock(x) SegHeapFree(x)
#define StructAlloc(x) ((x far *) SegHeapAlloc(sizeof(x)))
#define FreeStruct(x) SegHeapFree(x)
#define MemAlloc(x) MyLocalAlloc(x)
#define FreeMem(x) LocalFree(x)
#define PARAOF(x) ((x).para)
#define LINEOF(x) ((x).line)
#define POSOF(x) ((x).pos)
#define UNITOF(x,y) (PARAOF(x)->text[LINEOF(x)->position + y])
#define CHAROF(x,y) UNITOF(x,y).kanji
#define FORMATOF(x,y) UNITOF(x,y).format
#define POS2ABS(x) (LINEOF(x)->position + POSOF(x))
#define TOPPARA(x) PARAOF((x)->top)
#define TOPLINE(x) LINEOF((x)->top)
#define CURPARA(x) PARAOF((x)->current)
#define CURLINE(x) LINEOF((x)->current)
#define CURCHAR(x) POSOF((x)->current)
#define CURX(f) ((f)->cursor.x)
#define CURY(f) ((f)->cursor.y)
#define PSEUDOX(f) ((f)->pseudo.x)
#define PSEUDOY(f) ((f)->pseudo.y)
#define SELNOW(x) ((x)->sel.now)
#define SEL1(x) ((x)->sel.pos1)
#define SEL2(x) ((x)->sel.pos2)
#define SELPARA1(x) PARAOF(SEL1(x))
#define SELPARA2(x) PARAOF(SEL2(x))
#define SELPOS1(x) POSOF((x)->sel.pos1)
#define SELPOS2(x) POSOF((x)->sel.pos2)
#define SELCHAR1(x) (SELPARA1(x)->text[SELPOS1(x)])
#define SELCHAR2(x) (SELPARA2(x)->text[SELPOS2(x)])
#define SELTYPE(x) ((x)->sel.type)
#define RULER(x) ((x)->ruler)
#define BASEWIDTH(x) ((x)->basefont->width + (x)->leading)
#define RULERHEIGHT (2 * AVGHEIGHT)
#define BORDERSPACE (global.borderspace)
#define AVGWIDTH (global.textmetric.tmAveCharWidth)
#define AVGHEIGHT (global.textmetric.tmHeight + global.textmetric.tmExternalLeading)
#define STATUSHEIGHT (AVGHEIGHT * 1.3)
#define TBBORDER 6
#define TBICONHEIGHT 24
#define TBICONWIDTH 24
#define TBHEIGHT (TBICONHEIGHT + 2 * BORDERSPACE)
#define POS2PIXEL(x) (BORDERSPACE + (x) * BASEWIDTH(f) - f->startx)
#define LEFTMARGIN(x) ((LINEOF(x)->prev == NULL) ? PARAOF(x)->firstindent : PARAOF(x)->leftindent)
#define NEXTLINE(x) Skip(&(x), 1)
#define PREVLINE(x) Skip(&(x), -1)
/* Type definitions */
#define OP_MOVESEL 0x0001 /* Options for ReformatParagraph */
#define OP_UPDATE 0x0002
#define OP_MOVETOEND 0x0004
#define OP_REFORMAT 0x0008
#define OP_SAMELEN 0x0010
#define OP_MINIMAL 0x0020
#define OP_WITHFORMAT 0x0040
#define OP_CHOOSEKANJI 0x0080
#define FN_NORMAL 0x0001 /* Normal file */
#define FN_CLIPBOARD 0x0002 /* Clipboard */
#define FN_CONTROL 0x0004 /* A Japanese edit control */
#define FN_NOSWITCHING 0x0008 /* No mode switching at all times */
#define FN_EITHER 0x0010 /* Either ASCII or Japanese */
#define FN_NOKANJI 0x0020 /* No Kanji allowed */
#define FN_NOEDIT 0x0040 /* No editing allowed */
#define FN_NOSCROLLBARS 0x0080 /* Do not display scrollbars */
typedef enum { SEL_CONVERSION, SEL_SELECTION } SELTYPE;
typedef enum { M_KANA, M_ASCII } INPUTMODE;
typedef enum {
UN_INSERT, UN_DELETE, UN_INDENT, UN_SPLITLINE, UN_JOINLINE
} EDITACTION;
typedef enum {
J_LEFT, J_RIGHT, J_CENTER, J_JUSTIFY
} JUSTIFICATION;
typedef enum {
U_INSERT, U_DELETE, U_REPLACE, U_PARAFORMAT
} UNDOACTIONS;
typedef enum {
M_INCHES = 0,
M_CM = 1,
M_MM = 2,
M_POINTS = 3,
M_PIXELS = 4
} MEASUREMENT;
typedef struct {
char *name;
char *symbol;
int decimal;
double conversion;
} MEASUREINFO;
typedef enum {
FF_UNKNOWN = 0,
FF_NORMAL = 1,
FF_TEMPLATE = 2,
FF_EUC = 3,
FF_SJIS = 4,
FF_NEWJIS = 5,
FF_OLDJIS = 6,
FF_NEC = 7
} FILEFORMAT;
typedef struct UndoBufStruct {
int para1, start;
int para2, stop;
time_t time;
UNDOACTIONS action;
KANJI far *data;
struct UndoBufStruct far *next, far *prev;
} UNDOBUF;
typedef struct { /* The header for JWP's native format */
unsigned long int magic; /* Magic identifier */
char version[6]; /* Version number */
unsigned int paragraphs; /* Number of paragraphs */
float margins[4]; /* Left/Right/Top/Bottom margins, in inches */
int landscape:1; /* Landscape printing */
int summary:1; /* File summary exists */
int headers:1; /* Has header / footer */
int lrheader:1; /* Separate Left/Right pages in header/footer? */
int nofirstpage:1; /* Don't print header/footer on first page? */
unsigned int undo; /* Number of undo levels */
char extra[97]; /* Make it up to 128 bytes */
} FILEHEADER;
typedef struct {
unsigned int textsize; /* Number of characters in this paragraph */
unsigned int firstindent; /* Indentations */
unsigned int leftindent;
unsigned int rightindent;
} OLDFILEPARAHEADER100;
typedef struct {
unsigned int textsize; /* Number of characters in this paragraph */
unsigned int spacemulti; /* Spacing, x 100 */
unsigned char firstindent; /* Indentations */
unsigned char leftindent;
unsigned char rightindent;
unsigned char extra[9]; /* Pad it to 16 byte */
} FILEPARAHEADER;
typedef struct {
KANJI facename[NAMELEN/2]; /* Font family name */
int width, height; /* Width and height in pixels */
int charsize; /* Number of bytes that make up a character */
int verticals; /* The number of extra "vertical" characters */
long int offset; /* Byte offset to the beginning of bitmaps */
BOOL holes; /* Packed JIS coding or 93x93 with holes */
int leading, spacing; /* Horizontal / Vertical gaps */
char extra[6]; /* Make it up to 64 bytes */
} FONTHEADER;
typedef struct {